<template>
  <Modal v-model="modal" title="商品明细">
    <Table
      stripe
      :columns="columns"
      :data="tData"
    />
    <div slot="footer">
      <Button size="large" type="text" @click="modal = false">关闭</Button>
    </div>
  </Modal>
</template>
<script>
import { clearEmpty } from '@/util'
export default {
  data () {
    return {
      id: null,
      modal: false,
      btnDisabled: false,
      columns: [{
        title: '商品',
        key: 'productName'
      }, {
        title: '数量',
        key: 'totalQuantity'
      }],
      tData: []
    }
  },
  methods: {
    openModal () {
      this.modal = true
    },
    closeModal () {
      this.modal = false
    },
    getInfo (id, type, giftType, month, year) {
      this.tData = []
      this.openModal()
      let param = {
        giftType,
        storeId: id,
        month,
        year
      }
      param = clearEmpty(param)
      const url = type === 1 ? '/report/purch_gift_statistics/statistic_product' : '/report/purch_gift_statistics/task_product'
      this.$ajaxGet(url, param).then(data => {
        this.tData = data
      })
    }
  }
}
</script>
